|
|
|
|
|
|
|
In the General Declarations section, be sure the declaration looks like the following: |
|
|
|
|
|
|
|
|
Public Event OnWrongAccountNumber(argMsg As String) |
|
|
|
|
|
|
|
|
In the class FormController, enter the following declaration: |
|
|
|
|
|
|
|
|
Private WithEvents theBasicPersonalCheckingAccount As _
CheckDeposit.BasicPersonalChecking |
|
|
|
|
|
|
|
|
While in the same form, click the object list and select theBasicPersonalCheckingAccount. You should see the theBasicPersonalCheckingAccount_OnWrongAccountNumber event in the method/event list. In this event, enter the following code: |
|
|
|
|
|
|
|
|
theForm.lblAccountMaintForm(2).Caption = argMsg |
|
|
|
|
|
|
|
|
Make the Initialize event look like the following: |
|
|
|
|
|
|
|
|
Private Sub Class_Initialize()
mvarAccountNumber = 002
End Sub |
|
|
|
|
|
|
|
|
Make sure the TestCheckDeposit project is the startup (default) project. |
|
|
|
|
|
|
|
|
The value 002 is a dummy account number to test both the normal and abnormal paths of your use case. You can now run the application to test the normal path. Press F5. When your test form displays, enter 002 for the account number and 500 for the deposit amount. Click Store. When the component has finished processing the deposit request, the error message label will display Complete. To test the abnormal path, enter an account number different from 002. You will see the error message Wrong account number, Please retry. |
|
|
|
|
|
|
|
|
Finally, building the ActiveX component is easy. Simply choose File | Make CheckDeposit.dll from the menu. Your new component is registered with the operating system. To create an ActiveX EXE, start a new ActiveX EXE project and import the CheckDeposit files and projects to the new project and choose File | Make CheckDeposit.exe from the menu. |
|
|
|
|
|
|
|
|
This chapter teaches you how to plan, create, and test an ActiveX component. You learned the importance of use cases in test planning and of incorporating object-oriented testing services into ActiveX components. You then followed the sample test project for the Samsona Bank Teller System. Finally, you learned how to raise events in your component to trap business rule violations in the form of abnormal use case paths. In tomorrow's lesson, you will learn how to effectively use third-party controls in your applications. |
|
|
|
|
|